#ifndef MOVEABLE_H
#define MOVEABLE_H

#include <QObject>
#include <QMouseEvent>

class Moveable : public QObject
{
    Q_OBJECT
public:
    /**
     * @brief Moveable
     * @param trigger - the object accept mouse event
     * @param move - the object performance move, nullptr will be move [trigger]
     * @param parent - this object parent
     */
    explicit Moveable(QWidget *trigger, QWidget *mover, QObject *parent = nullptr);

    void setEnabled(bool enable);
    void setPadding(int padding);
    void setPadding(int top, int left, int bottom, int right);

signals:

protected:
    virtual bool eventFilter(QObject *w, QEvent *e);
    virtual void onMoveEvent(QMouseEvent *event);
    virtual void onPressEvent(QMouseEvent *event);
    virtual void onReleaseEvent(QMouseEvent *event);
    virtual void onDoubleClickEvent(QMouseEvent *event);

private:
    QWidget *_trigger,*_mover;
    bool _isEnabled;
    int _topPadding,_leftPadding,_bottomPadding,_rightPadding;
    bool _isMousePressed;
    QPoint _posPressed;
};

#endif // MOVEABLE_H
